package 
{
	import chamans.away.sol;
	import chamans.away.chair;
	import chamans.engine.Away4;
	import chamans.engine.Bullet;
	import chamans.life.PoissonDisk;
	import flash.geom.Vector3D;
	[SWF(backgroundColor="#000000", frameRate="120", width="960", height="540")]
	public class baseBullet extends Away4
	{
		public function baseBullet()
		{
			var DEF:Object={  phy:true, fog:true, reflect:true, sky:true,
				titre:"3DFLASHLO",  
				e:"away" , e2:"bullet", v:3317, v2:22,
				message:"SPACE generate chair  C on-off complex rigid",
				//[ground, sky, building, fog, fogDistance, quality:0/1/2, hazeAlpha, construct ]
				color:[0x8E806F, 0x195BB2, 0x6491CC, 0x7F7468, 600, 0, 1, false, true],// config base
				// camera set
				fov:50, far:3500, near:1, type:"fps", H:90, V:-90,  
				position : new Vector3D(0, 100, -200), targetDistance :1000
			}
			super(INIT3D, GETKEYS, DEF);
		}
		private function INIT3D():void
		{   
			Lights.add("point", 0xeeEFff, -405, 330, -405, .8, 1, false , null, true ,300, 3000);
			Lights.add("point", 0xFFEFee, 405, 330, -405, .8, 1, false , null, true ,300, 3000);
		//	Lights.add("direct", 0xeeeeFF, .3, .3, -1,.9, 1, false , null, false ,300, 3000);
			if(phyOn){ 
				physics = new Bullet( this, 0.008, 0.1, 2 );
				physics.add_Plan(.3, .8);
			}
			Camera.plan( 'mapbase', .3 , new Vector3D(50,.5,2048), null, TMP);
		}	
		private function TMP():void
		{
			G = new sol( this, NEXT0);
			SYS.VISOR( true ); 
		}
		private function NEXT0():void {  
			C = new chair( this, RESET, new Vector3D(), false  );
			//Deep(5,5, 1500);
			Shadows(1);
		}
		public function RESET():void {
			if(actif){C.Delete();actif=false;}
			C.complex=complex;
			var i:int;
			var W:int=2048;
			var MAXI:int=40//TOOL.Ran(50, 10)
			var sampler:PoissonDisk = new PoissonDisk({w:W, max:MAXI, fail:MAXI ,
				// Dmap:Camera.planTop.mapDistrib,
				Hmap: Camera.planTop.mapDistrib,
				Rmin:2, Rmax:10
			});
			for each( var p:Vector3D in sampler.List)
			C.clone(new Vector3D(p.x-(W>>1), TOOL.Ran(1000, 200), p.y-(W>>1)),new Vector3D(0, sampler.List[i].z,0) );//43
			sampler.List=null;
			actif=true;
		}
		private function GETKEYS():void 
		{	
			if( KEY.isDown( 32 ) && Ppress){ RESET(); Ppress=false; }// space
			if( KEY.isUp( 32 ) && actif)Ppress=true;
			if( KEY.isDown( 67 ) && Cpress){// c
				if(complex)complex=false; 
				else complex=true;
				SYS.OUT("Complex Rigid : " + complex);
				RESET(); Cpress=false;
			}
			if( KEY.isUp( 67 ) && actif)Cpress=true;
		}
		private var G:sol;
		private var C:chair;
		private var Cpress:Boolean=true;
		private var Ppress:Boolean=true;
		private var actif:Boolean=false;
		private var complex:Boolean=false;
	}}
